package com.xinzhang.base;


import java.io.IOException;

import com.helper.ImageHelper;
import com.helper.SqlLiteHepler;

import android.content.Context;
import android.graphics.Bitmap;


public class ImageCash {

	private static String keypath="/sdcard/temp_filter";
	
	public static void AddBitmap(Context context,int index,Bitmap bitmap) throws IOException {
		
//		File myCaptureFile=new File(keypath+"_"+index+".jpg");
//		BufferedOutputStream bos;
//		bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
//		bitmap.compress(Bitmap.CompressFormat.JPEG, 100,bos);
//		bos.flush();
//		bos.close();
		SqlLiteHepler sqlLiteHepler=new SqlLiteHepler(context);
		sqlLiteHepler.AddTempBitmap(index,ImageHelper.BitmapToBytes(bitmap,100));
		sqlLiteHepler.Close();
		
	}
	public static Bitmap getBitmap(Context context,int index) {
		SqlLiteHepler sqlLiteHepler=new SqlLiteHepler(context);
		byte[] data=sqlLiteHepler.GetTempBitmap(index);
		sqlLiteHepler.Close();
		return ImageHelper.Bytes2Bimap(data);
		//return BitmapFactory.decodeFile(keypath+"_"+index+".jpg");
	}

}
